package com.heima.wemedia.feign;

import com.heima.feign.wemedia.IWemediaClient;
import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.wemedia.pojos.WmBaiduToken;
import com.heima.model.wemedia.pojos.WmSensitive;
import com.heima.wemedia.mapper.WmBaiduTokenMapper;
import com.heima.wemedia.mapper.WmSensitiveMapper;
import com.heima.wemedia.service.WmChannelService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class WemediaClient implements IWemediaClient {

    @Autowired
    private WmChannelService wmChannelService;
    @Autowired
    private WmBaiduTokenMapper wmBaiduTokenMapper;
    @Autowired
    private WmSensitiveMapper wmSensitiveMapper;

    @GetMapping("/api/v1/channel/list")
    @Override
    public ResponseResult getChannels() {
        return ResponseResult.okResult(wmChannelService.list());
    }

    @GetMapping("/api/v1/baidu_token")
    public WmBaiduToken getToken(){
        return wmBaiduTokenMapper.selectList(null).get(0);
    }

    @GetMapping("api/v1/sensitive/list")
    public List<WmSensitive> list(){
       return wmSensitiveMapper.selectList(null);
    }
}